#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <strings.h>
#include <unistd.h>
#include <sys/mman.h>

#include <sys/time.h>

#define LCD_DEV "/dev/fb0"
#define WIDTH 800
#define HEIGHT 480
#define BIT_DEPTH 4

#define DEBUG_ON 0
#define DEBUG_OFF 1
#define DEBUG DEBUG_ON
#define debug_info(...) DEBUG?1 : printf(__VA_ARGS__)

#define true 1
#define false 0
typedef unsigned char bool;


/*
* DESCRIPTION:
* 	Do some cleaning.
*/
void close_display();


bool fill_screen(int color);


/*
* DESCRIPTION:
*	Lazy.
*/
bool init_display(void);


/* 
* DESCRIPTION:
* 	Set the color of a specific pixel at pos_x and pos_y.
*	And of course, pos_x and pos_y should be greater than 0,
*	but I don't have the energy to check it. So it's the 
*	invoker(you)'s responsibility now.
*	
* TODO:
*	return bool value to indicate if color successfully
*	set.
* 
* NOTE:
*	The type of _int color_ seems not very portable, 
* 	as it assumes that one int occupies 4 bytes room .
*/
bool set_at(int pos_x, int pos_y, int color);


/*
* DESCRIPTION:
*	Fill the screen with given color. It is could used
*	to clear the screen.
*/


/***********************************
* TIME RELATIVE
************************************/
unsigned long get_time();
void delay(int milliseconds);
void rate(int freq);


/***********************************
* GLOBAL VARIABLES
************************************/
extern int lcd_fd;
extern int *p_lcd_map;






